<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>系统后台 - Tpcms内容管理系统 - by Tpcms</title>
<link href="/dwz/./Core/Tpcms/Admin/View/Public/css/admin_style.css" rel="stylesheet" />
<link href="/dwz/Core/Org/artDialog/skins/default.css" rel="stylesheet" />
<script type="text/javascript">
//全局变量
var GV = {
    DIMAUB: "/dwz/",
	JS_ROOT: "/dwz/Core/Org/"
};
</script>
<script src="/dwz/Core/Org/wind.js"></script>
<script src="/dwz/Core/Org/jquery.js"></script>
</head>
<body class="J_scroll_fixed">
<div class="wrap J_check_wrap">
	<div class="nav">
		<ul class="cc">
			<li class="current">
				<a href="javascript:;">附件管理</a>
			</li>
		</ul>
	</div>
	<div class="h_a">搜索</div>
	<form method="get" action="<?php echo U('index');?>">
		<div class="search_type cc mb10">
			<div class="mb10">
				<span class="mr20">
					上传时间：
					<input type="text" name="start_time" class="input length_2 J_date" value="<?php echo ($_GET['start_time']); ?>" placeholder="选择时间">
					-
					<input type="text" class="input length_2 J_date" name="end_time" value="<?php echo ($_GET['end_time']); ?>" placeholder="选择时间">
					附件类型：
					<input type="text" class="input length_2" name="ext" style="width:80px;" value="<?php echo ($_GET['ext']); ?>" placeholder="jpg、png...">
					使用状态：
					<select name="status" id="status" >
						<option value="0" <?php if(isset($_GET["status"]) && $_GET["status"] == "0"): ?>selected='selected'<?php endif; ?>>全部</option>
						<option value="1" <?php if(isset($_GET["status"]) && $_GET["status"] == "1"): ?>selected='selected'<?php endif; ?>>已经在使用</option>
						<option value="2" <?php if(isset($_GET["status"]) && $_GET["status"] == "2"): ?>selected='selected'<?php endif; ?>>没有被使用</option>
					</select>
					附件名称：
					<input type="text" class="input length_2" name="keyword" style="width:200px;" value="<?php echo ($_GET['keyword']); ?>" placeholder="请输入附件名称...">
					<button class="btn">搜索</button>
				</span>
			</div>
		</div>
	</form>
	<form name="myform" action="" method="post" class="J_ajaxForm">
		<div class="table_list">
			<table width="100%" cellspacing="0">
				<thead>
					<tr>
						<td width="45" align="center">
							<input type="checkbox" class="J_check_all" data-direction="x" data-checklist="J_check_x">全选
						</td>
						<td width="40" align="center">ID</td>
						<td width="70" align="center" >上传用户</td>
						<td>附件名称</td>
						<td width="260" align="left">路径</td>
						<td width="100" align="left">附件大小</td>
						<td width="120" align="center">上传时间</td>
						<td width="100" align="center">管理操作</td>
					</tr>
				</thead>
				<tbody>
					<?php if($data): if(is_array($data)): $i = 0; $__LIST__ = $data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$value): $mod = ($i % 2 );++$i;?><tr>
						<td align="left">
							<input type="checkbox" class="J_check" data-yid="J_check_y" data-xid="J_check_x" name="id[<?php echo ($value["id"]); ?>]" value="<?php echo ($value["id"]); ?>" id="att_5" />
						</td>
						<td align="center"><?php echo ($value["id"]); ?></td>
						<td align="center"><?php echo ($value["username"]); ?></td>
						
						<td >
							<table >
								<tr>
									<td align="left" width="24" style="padding:0;background:none">
										<?php echo ($value["preview"]); ?>
									</td>
									<td align="left" style="padding:0;;background:none">
										<?php echo ($value["name"]); ?>
									</td>
								</tr>
							</table>
							
						</td>
						<td align="left"><?php echo ($value["path"]); ?></td>
						<td align="left"><?php echo (get_size($value["size"])); ?></td>
						<td align="center"><?php echo (format_date($value["addtime"])); ?></td>
						<td align="center">
							<?php if($value["is_jpg"]): ?><a href="javascript:preview(<?php echo ($value["id"]); ?>, '<?php echo ($value["remark"]); ?>','/dwz/<?php echo ($value["path"]); ?>/<?php echo ($value["name"]); ?>')">预览</a>
							<?php else: ?> 
							<a href="<?php echo U('down',array('id'=>$value['id']));?>">下载</a><?php endif; ?>
							|
							<a class="J_ajax_del" href="<?php echo U('del',array('id'=>$value['id']));?>">删除</a>
						</td>
					</tr><?php endforeach; endif; else: echo "" ;endif; ?>
					<?php else: ?>
					<tr><td colspan="8">没有找到符合条件的记录</td></tr><?php endif; ?>
				</tbody>
			</table>
			<div class="p10">
				<div class="pages"></div>
			</div>
		</div>
		<div class="btn_wrap">
			<div class="btn_wrap_pd">
				<label class="mr20">
					<input type="checkbox" class="J_check_all" data-direction="y" data-checklist="J_check_y">全选</label>
				<button class="btn btn_submit mr10 J_ajax_submit_btn" type="submit" data-action="<?php echo U('bathdelete');?>">删除附件</button>
			</div>
		</div>
	</form>
</div>
<script src="/dwz/Core/Org/common.js"></script>
<script src="/dwz/Core/Org/content_addtop.js"></script>
<script type="text/javascript">
//附件预览
function preview(id, name, filepath) {
    if (IsImg(filepath)) {
        Wind.use('artDialog', 'imgready', function () {
            imgReady(filepath, function () {
                var width = 0,
                    maxWidth = 500,
                    maxHeight = 500,
                    height = 0;
                var hRatio;
                var wRatio;
                var Ratio = 1;
                var w = this.height;
                var h = this.width;
                wRatio = 500 / this.height;
                hRatio = 500 / this.width;

                if (maxWidth == 0) { //
                    if (hRatio < 1) Ratio = hRatio;
                } else if (maxHeight == 0) {
                    if (wRatio < 1) Ratio = wRatio;
                } else if (wRatio < 1 || hRatio < 1) {
                    Ratio = (wRatio <= hRatio ? wRatio : hRatio);
                }
                if (Ratio < 1) {
                    w = w * Ratio;
                    h = h * Ratio;
                }
                width = h;
                height = w;

                art.dialog({
                    title: '预览',
                    fixed: true,
                    width: width,
                    height: height,
                    id: "image_priview",
                    lock: true,
                    background: "#CCCCCC",
                    opacity: 0,
                    content: '<img src="' + filepath + '"  width="' + width + '" height="' + height + '" />'
                });

            });
        });
    } else {
        Wind.use('artDialog', function () {
            art.dialog({
                title: '预览',
                padding: 0,
                width: 230,
                height: 150,
                content: '<a href="' + filepath + '" target="_blank"><img src="/tool/shuipfcms/statics/images/icon/down.gif">单击打开</a>',
                lock: true
            });
        });
    }
}

//缩图管理
function showthumb(id, name) {
    Wind.use('artDialog', 'iframeTools', function () {
        art.dialog.open(GV.DIMAUB + 'index.php?a=public_showthumbs&m=Admin&g=Attachment&aid=' + id, {
            title: '管理缩略图--' + name,
            padding: 0,
            width: '500px',
            height: '400px',
            lock: true,
            background: "#CCCCCC",
            opacity: 0
        });
    });
}
</script>
</body>
</html>